package meatslope2.application;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.View;

public class Application extends FragmentActivity 
{
	public static String MESSAGE = "meatslope.application.MESSAGE";
	
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_application);
        
        //Dynamically add testing_fragment
        TestingFragment testingFragment = new TestingFragment();
        
        // Add the fragment to the 'fragment_container' FrameLayout
        getSupportFragmentManager().beginTransaction()
                .add(R.id.framework_container, testingFragment).commit();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        getMenuInflater().inflate(R.menu.activity_application, menu);
        return true;
    }
    
    /**
     * Called when the user selects the "Start" button 
     * @param view
     */
    public void startGame(View view) 
    {
        Intent intent = new Intent(this, DisplayMessageActivity.class);
        
        String message = "poop balls";
        intent.putExtra(MESSAGE, message);
        
        startActivity(intent);
    }
    
    /**
     * Called when the user selects the "Switch Fragment" button 
     * @param view
     */
    public void switchFragment(View view)
    {
    	// Create fragment and give it an argument specifying the article it should show
    	AnotherFragment newFragment = new AnotherFragment();
    	Bundle args = new Bundle();

    	FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    	// Replace whatever is in the fragment_container view with this fragment,
    	// and add the transaction to the back stack so the user can navigate back
    	transaction.replace(R.id.framework_container, newFragment);
    	transaction.addToBackStack(null);

    	// Commit the transaction
    	transaction.commit();
    }
}
